import{$}from "./ajax.js";
  let goodlist={
    showGoods:function(){
        var p=new Promise(function(resolve,reject){
        $.ajax({url:"goodlist.php",
                type:"get",
                dataType:"json",
                callback:function(e){
                   resolve(e)
                }})
        })
        return p
    },
    showdetail:function(good_id){
        var p=new Promise(function(resolve,reject){
                $.ajax({url:"goodlist.php",
                        type:"get",
                        data:{good_id:good_id},
                        callback:function(e){
                           resolve(e)
                        }})
                })
                return p
    },
    addCar:function(user_id,user,good_id,goods_title,goods_num,goods_current_price,goods_pic){
        var p=new Promise(function(resolve,reject){
                $.ajax({data:{
                        user_id:user_id,
                        user_name:user,
                        goods_id:good_id,
                        goods_name:goods_title,
                        goods_num:goods_num,
                        goods_price:goods_current_price,
                        goods_pic:goods_pic
                    },
                url:"addtocar.php",
                dataType:"json",
                callback:function(e){
                        resolve(e)
                }})
                })
                return p   
    },
    shoppingcar:function(user_id){
        var p=new Promise(function(resolve,reject){
        $.ajax({data:{
                user_id:user_id},
                url:"shoppingcar.php",
                dataType:"json",
                callback:function(e){
                        resolve(e)
                }})
                })
                return p   
    }
}

export {goodlist}
